<template>
  <view class="cu-image" :style="styles">
  	<image :style="styles" :mode="mode" :src="getimgsrc" ></image>
  </view>
</template>

<script>
import { fileUrl } from '@/common/config.js';

export default {
  name: 'cu-image',
  props: {
    src: {
      type: String,
      default: ''
    },
    styles: {
      type: String,
      default: ''
    },
	mode: {
		type: String,
		default: 'aspectFill'
	}
  },
  data() {
    return {
     imgsrc: '',
    };
  },
  created() {

  },
  computed:{
	  getimgsrc(){
	  	let src = '';
	  	if(this.src && this.src.indexOf('static') > -1){
	  		return this.src;
	  	}
	  	if(this.src && this.src.indexOf('/storage') == 0){
	  	  src = `${fileUrl}${this.src}`;
	  	}
		if(this.src && this.src.indexOf('http') == 0){
		  src = this.src;
		}
	  	return src;
	  }
  },
  methods: {
    
  }
};
</script>

<style scoped>
  /* .cu-image { display: inline-flex; height: 100%;width: 100%;justify-content: center;}
  .cu-image uni-image { width: 100%; display: block; height: 100%; margin: 0;} */
</style>
